package com.czl.module_service.adapter;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.TimeUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder;
import com.czl.base.data.bean.tengyun.HealthReportBean;
import com.czl.module_service.R;
import com.czl.module_service.databinding.ItemHealthReportBinding;

import java.util.Date;

public class HealthReportAdapter extends BaseQuickAdapter<HealthReportBean.Data, BaseDataBindingHolder<ItemHealthReportBinding>> {
    public HealthReportAdapter(int layoutResId) {
        super(layoutResId);
    }

    private String healthyName = "";

    @Override
    protected void convert(@NonNull BaseDataBindingHolder<ItemHealthReportBinding> itemHealthReportBindingBaseDataBindingHolder, HealthReportBean.Data data) {
        System.out.println("111111");
        ItemHealthReportBinding viewBinding = itemHealthReportBindingBaseDataBindingHolder.getDataBinding();
        viewBinding.tvTitle.setText(TimeUtils.date2String(
                new Date(data.getHealthyTime()),
                "yyyy-MM-dd HH:mm"
        ) + " 健康上报");
        if (data.getHealthyType() == 0) {
            viewBinding.ivPic.setImageResource(R.mipmap.ic_healthy);
            healthyName = "健康";
        } else if (data.getHealthyType() == 1) {
            viewBinding.ivPic.setImageResource(R.mipmap.c_love);
            healthyName = "发热";
        } else if (data.getHealthyType() == 2) {
            viewBinding.ivPic.setImageResource(R.mipmap.h_love);
            healthyName = "疑似";
        } else if (data.getHealthyType() == 3) {
            viewBinding.ivPic.setImageResource(R.mipmap.red_love);
            healthyName = "确诊";
        } else if (data.getHealthyType() == 4) {
            viewBinding.ivPic.setImageResource(R.mipmap.ic_healthy);
            healthyName = "已治愈";
        } else {
            viewBinding.ivPic.setImageResource(R.mipmap.ic_healthy);
            healthyName = "其他";
        }
        viewBinding.tvStatus.setText("健康状况：" + healthyName + " 、 " + data.getTemperature() + " ℃");
    }

}
